diff --git a/etc/nginx/lua/balancer.lua b/etc/nginx/lua/balancer.lua
index 00104c89d..b9d1f3573 100644
--- a/etc/nginx/lua/balancer.lua
+++ b/etc/nginx/lua/balancer.lua
@@ -120,6 +120,13 @@ local function sync_backend(backend)
 
   if not balancer then
     balancers[backend.name] = implementation:new(backend)
+    if backend.ingress then
+      balancers[backend.name]["ingress_name"] = backend.ingress.metadata.name
+    end
+    if backend.service then
+      balancers[backend.name]["backend_name"] = backend.service.metadata.name
+      balancers[backend.name]["backend_port"] = backend.port
+    end
     return
   end
 
@@ -131,6 +138,13 @@ local function sync_backend(backend)
         string.format("LB algorithm changed from %s to %s, resetting the instance",
                       balancer.name, implementation.name))
     balancers[backend.name] = implementation:new(backend)
+    if backend.ingress then
+      balancers[backend.name]["ingress_name"] = backend.ingress.metadata.name
+    end
+    if backend.service then
+      balancers[backend.name]["backend_name"] = backend.service.metadata.name
+      balancers[backend.name]["backend_port"] = backend.port
+    end
     return
   end
 
@@ -330,6 +344,12 @@ function _M.balance()
     return
   end
 
+  if balancer["ingress_name"] then ngx.var.ingress_name = balancer["ingress_name"]:gsub("%-rwr", "") end
+  if not (ngx.var.proxy_upstream_name == "upstream-default-backend") then
+    if balancer["backend_name"] then ngx.var.service_name = balancer["backend_name"] end
+    if balancer["backend_port"] then ngx.var.service_port = balancer["backend_port"] end
+  end
+
   local peer = balancer:balance()
   if not peer then
     ngx.log(ngx.WARN, "no peer was returned, balancer: " .. balancer.name)
